<template>
  <div class="clearfix table-out search">
    <el-button
        type="primary"
        plain
        size="small"
        class="return pointer"
        @click="returnGo"
    ><i class="iconfont icon-fanhui"></i> 返回
    </el-button>

    <div class="clearfix top-return search-pub">
      <el-form :model="formData" label-width="auto">
        <el-select class="fxl margin10R" @change="getData"
                   v-model="formData.jinjqrzt"
                   placeholder="晋级确认状态"
                   style="width: 120px"
        >
          <el-option
              v-for="item in pingsztlb"
              :key="item.id"
              :label="item.itemText"
              :value="item.itemValue"
          />
        </el-select>

        <el-select class="fxl margin10R" clearable
                   v-model="formData.saisjc" @change="getData"
                   placeholder="请选择赛事进程"
                   style="width:180px">
          <el-option
              v-for="item in saisjclb"
              :key="item.id"
              :label="item.jincmc"
              :value="item.id"
          />
        </el-select>

        <el-input class="fxl margin10R" clearable
                  v-model="formData.zuopbt"
                  style="width: 240px"
                  placeholder="请输入作品标题"
        />
        <el-cascader class="fxl margin10R" clearable
                     @change="cascaderChange"
                     :show-all-levels="true"
                     placeholder="请选择赛区"
                     :props="props"
                     v-model="formData.saiq"
                     :options="options"
        ></el-cascader>
        <el-button class="fxl" type="primary" @click="getData()">查询</el-button>
        <el-button class="fxl" type="primary" @click="reset">重置</el-button>
      </el-form>
    </div>

    <el-table
        :data="tableData" empty-text=" "
        class="tablePub top-return"
        :row-class-name="tableRowClassName"
    >
      <!--      <el-table-column prop="no" label="序号" width="70">-->
      <!--        <template #default="scope">-->
      <!--          <p>{{ scope.$index + 1 }}</p>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <el-table-column label="序号" type="index" :index="getIndex" width="70"/>
      <!-- <el-table-column prop="createBy" label="提交人"></el-table-column> -->
      <el-table-column prop="createTime" label="创建时间" width="180"></el-table-column>
      <el-table-column prop="saisjc_dictText" label="赛事进程" width="120"></el-table-column>
      <el-table-column prop="saiq" label="赛区" width="140"></el-table-column>
      <el-table-column prop="zuopbt" label="作品"></el-table-column>
      <el-table-column prop="pingjf" label="平均分" width="80"></el-table-column>
      <el-table-column prop="fuhf" label="复核分" width="80"></el-table-column>
      <el-table-column prop="zuizf" label="最终分" width="80"></el-table-column>
      <el-table-column prop="defpm" label="得分排名" width="80"></el-table-column>
      <el-table-column prop="jinjqrzt_dictText" label="晋级确认状态" width="120"></el-table-column>
      <el-table-column prop="jinjqrjg_dictText" width="120" label="晋级确认结果"></el-table-column>

      <!-- v-if="scope.row.jinjqrzt == 1" -->
      <el-table-column label="操作" width="160">
        <template #default="scope">
          <el-button v-if="scope.row.jinjqrzt=='1'"
                     type="primary"
                     size="small"
                     @click="oper(scope.$index, scope.row,1)"
          >晋级确认
          </el-button
          >
          <el-button v-if="scope.row.jinjqrzt=='2'"
                     size="small"
                     @click="oper(scope.$index, scope.row,2)"
          >查看
          </el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        v-model:current-page="pageNo"
        v-model:page-size="pageSize"
        @current-change="handleCurrentChange"
        small
        background
        layout="total, prev, pager, next"
        :total="total"
        class="pagination fxr"
    />
  </div>
</template>

<script>
import pubJs from "./pub";
import axios from "axios";

export default {
  mixins: [pubJs],
  data() {
    return {
      saisId: null,
      formData:{
        jinjqrzt: '1',
        saisjc: '',
        zuopbt: '',
        saiq: '',
      },
      userInfo: JSON.parse(localStorage.getItem("userInfo")),
    };
  },

  inject: ["imageUrl", "serviceUrl"],

  mounted() {
    let that = this;
    that.saisId = this.$route.query.saisId;
    that.getOptionsData("C05");
    that.dictItemList("1787331449824313345")
    that.cdba2SaisjcData()
    this.searchFormData = JSON.parse(localStorage.getItem('searchFormData'))
    if (this.searchFormData && Object.keys(this.searchFormData).length != 0) {
      this.formData.jinjqrzt = this.searchFormData.jinjqrzt ? this.searchFormData.jinjqrzt : ''
      this.formData.pingszt = this.searchFormData.pingszt ? this.searchFormData.pingszt : ''
      this.formData.saisjc = this.searchFormData.saisjc ? this.searchFormData.saisjc : ''
      this.formData.zuopbt = this.searchFormData.zuopbt ? this.searchFormData.zuopbt : ''
      this.formData.saiq = this.searchFormData.saiq ? this.searchFormData.saiq : ''
      this.pageNo = this.searchFormData.pageNo ? this.searchFormData.pageNo : ''
    }
    setTimeout(()=>{
      this.getData(this.pageNo);
    },200)
  },

  methods: {

    oper(index, row) {
      localStorage.setItem("topStepId", row.saisjc);
      localStorage.setItem('searchFormData', JSON.stringify({...this.formData, pageNo: this.pageNo}))
      this.$router.push({
        path: "jinjqr_detail",
        query: {
          id: row.id,
          saisId: row.sais,
          canszpId: row.zuopId,
          saisjcId: row.saisjc,
          pingszt: row.pingszt,
          jinjqrzt:row.jinjqrzt,
          jinjqrjg: row.jinjqrjg
        },
      });
    },

    returnGo() {
      this.$router.go(-1); // 返回上一个页面
    },

    reset() {
      this.formData = { jinjqrzt: '1',saisId: this.saisId};
      this.pageNo = 1
      this.getData();
    },

    getData() {
      let that = this;
      axios
          .get(that.serviceUrl + "/jinjqr2/cbda2Jinjqr/list2", {
            headers: {
              "X-Access-Token": localStorage.getItem("token"),
            },
            params: {
              ...that.formData,
              sais: that.saisId,
              zuopbt: that.formData.zuopbt ? '*' + that.formData.zuopbt + '*' : '',
              column: "createTime",
              order: "desc",
              pageSize: this.pageSize,
              pageNo: this.pageNo,
              _t: new Date().getTime(),
            },
          })
          .then((resp) => {
            that.tableData = resp.data.result.records;
            this.total = resp.data.result.total;
            this.pageSize = resp.data.result.size;
          })
          .catch((error) => {
            //console.log(error);
          });
    },
  },
};
</script>

<style scoped lang="less"></style>
